;(function(){
	 $("body").on('click','[data-stopPropagation]',function (e) {
        e.stopPropagation();
    });
	//需要立即执行的初始化操作
	var windows_init={
		init_toastr:function(){init_toastr();},
		init_url:function(url){init_url(url);},
	}
	function init_top(){
		var $shop_id=$("#sync_shop_id").val();
		$.post(
			'/Api/GymApi/getFaceCode',
			{
				"card_no":'getall',
				"shop_id":$shop_id,
			},
			function(data){
				 if(data.flag){
					var $signs=data.data.signs;
					var $count=data.data.count;
					$("#sign_count").text($count);
					$("#sign_list").empty();
					$.each($signs,function(index,value){
						$content='<div class="col-sm-2"><div class="col-sm-12"><img alt="暂无图片" src="';
						$content+=value['icon1']+'"';//'https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=3349216825,2698183703&fm=179&app=42&f=JPEG?w=121&h=140"';
						$content+=' style="width: 100%;max-height: 80px;" class="img-circle" style="margin: 1px;" /></div><div class="col-sm-12 text-center"><span class="span3">';
						$content+=value['name'];
						$content+=' </span></div></div>';
						$("#sign_list").append($content);
					});
				 	//toastr['success']("成功"); 
				 }else{
				 	//toastr['error'](data.msg);
				 }
			}
		);
		return false;
	}
	//二级菜单点击事件
	$(".menu_2").on("click",function(){menu_3_click($(this))});
	// 列表页刷新按钮
	$("body").on("click","#myform #btn-advanced-refresh",function(){
		$("#myform")[0].reset();
		$('.select2-single').select2("val","0");
		$('.js-example-basic-single').select2("val","0");
		$("#myform #btn-advanced-search").trigger("click");// 刷新页面
	});
	//全选按钮
	$("body").on("click","#div-table-container .selecte_all",function(){
		  var flag=$(this).is(":checked");
		  if(flag){
		  	 $("#div-table-container input[name='ids']").prop("checked",true);
		  	 $("#div-table-container .selecte_all").prop("checked",true);
		  }else{
		  	 $("#div-table-container input[name='ids']").prop("checked",false);
		  	 $("#div-table-container .selecte_all").prop("checked",false);
		  }
	});
	//选择tr 选择 checkbox
	$("body").on("click","#div-table-container #data-table tr",function(e){
		 if(e.target.tagName!='INPUT'){
		 	 var flag=$(this).find("input[name='ids']:first").is(":checked");
			 if(flag){
			 	$(this).find("input[name='ids']:first").prop("checked",false);
			 }else{
			 	$(this).find("input[name='ids']:first").prop("checked",true);
			 }
		 }
		 e.stopPropagation();
	});
	init();
	
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//初始化事件
	function init(){
		windows_init.init_url($.hash("code"));
		windows_init.init_toastr();
		window.layers=layer;
		window.loading=function(){window.layers.load(2)};//调用方式 直接 loading();
 		window.close_loading=function(){window.layers.closeAll('loading')};//调用方式 直接 close_loading();
 		window.delete_dialog=function(url,msg,refresh,delete_model_card_no){delete_dialog(url,msg,refresh,delete_model_card_no)}//调用方式 delete_dialog(url);
		window.export_dialog=function(url){export_dialog(url)}//调用方式 delete_dialog(url);
 		window.init_parsley=function(){init_parsley();}//调用方式 init_parsley();
 		window.clear_store=function(flag){clear_store(flag);}//清理柜子
 		window.clear_store_zyd=function(){clear_store_zyd();}//中央店 清理 c1-c80 柜子
 		window.read_cupno=function(){read_cupno();}//查询柜号
 		window.read_card_code_btn=function(node){read_card_code_btn(node);}
 		window.set_staff_card=function(obj){return  set_staff_card(obj);}
 		window.read_no_member=function(){read_no_member();}//柜子号查询会员 查询卡
 		window.fetch_card=function(card_no){fetch_card(card_no)}  //匹配卡
 		window.store_set_dailog=function(){store_set_dailog();}
 		
 		window.sign_finger1=function(){sign_finger1();}//获取第一个指纹
 		window.sign_finger2=function(){sign_finger2();}//获取第二个指纹
 		// 指纹回调函数
 		window.SignFinger1CallBack=function(data){SignFinger1CallBack(data);}
 		window.SignFinger2CallBack=function(data){SignFinger2CallBack(data);}
 		window.FingerDataCallBack=function(data){FingerDataCallBack(data);}
 		//获取人脸
 		window.open_camare=function(type){open_camare(type);}  //打开照相机
 		window.get_face_code=function(){get_face_code();}
 		window.get_face_url=function(){get_face_url();}
 		
 		//写 指纹txt
 		window.write_txt_face=function(card_no,datas){write_txt_face(card_no,datas);}
 		//写人脸数据txt
 		window.write_txt_finger=function(card_no,datas){write_txt_finger(card_no,datas);}
 		//获取安科会员数据
 		window.get_member_info=function(card_no){get_member_info(card_no);}
 		
 		window.read_staff_card_btn=function(node,flag,open_door){read_staff_card_btn(node,flag,open_door);}
 		//设备重链接
 		window.reconnect=function(){reconnect();}
 		//模板下载
 		window.sync_card_no_btn=function(){
 			sync_card_no_btn();
 		}
 		//清理之前的模板
 		window.clear_model=function(card_no){
 			clear_model(card_no);
 		}
 		//通电储物柜
 		window.common_cabinet=function(){
 			common_cabinet();
 		};
 		//关闭自动读卡
 		window.js_stop_auto_read=function(){js_stop_auto_read();}
 		//开启自动读卡
 		window.js_start_auto_read=function(){js_start_auto_read();}
 		//设置水泵
 		window.set_water_pump=function(type,count,minute){return set_water_pump(type,count,minute);}
 		//设置水泵
 		window.get_water_pump=function(){return get_water_pump();}
 		//获取自动读卡状态
 		window.is_auto_read=function(){is_auto_read();}	
 		window.login_out=function(){login_out();}
 		window.focus_refresh=function(){focus_refresh();}
 		window.clear_cache=function(){clear_cache();}
 		$.fn.datepicker.dates['zh-CN'] = {
	        days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
	        daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
	        daysMin:  ["日", "一", "二", "三", "四", "五", "六"],
	        months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
	        monthsShort: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
	        today: "今日",
	        clear: "清除",
	        format: "yyyy年mm月dd日",
	        titleFormat: "yyyy年mm月",
	        weekStart: 1
    	};
    	init_top();
	}
    function login_out(){
    	window.location.href="/admin/main/login_out";
    }
    function focus_refresh(){
    	window.location.href="/admin/main/index?to_login=1&t="+new Date().getTime();
    }
    //清理缓存
    function clear_cache(){
    	$.post(
    		"/Admin/Main/clear_cache",
    		function(data){
  				toastr["success"](data.msg,"成功");  			
    		}
    	);
    }
	//初始化url
	function init_url(url){
		if(url!=null&&typeof(url)!='undefined'){//第二次进入后台
			var auth_code='';
			try{
				$("#sidebar").children().removeClass("active");
				auth_code=code_spilt($.base64.decode(url));
				setTimeout(function(){$("#"+auth_code[0]).trigger("click");},500);
				setTimeout(function(){$("#"+auth_code[1]).trigger("click");},800);				
			}catch(e){
				alert("禁止非法访问！！！！");					
			}
		}else{// 第一次进入后台
			$("#sidebar").children().removeClass("active").eq("1").addClass("active")
			console.log("the first time in");
		}
	}
	/**二级菜单点击事件*/
	function menu_3_click(node){
			loading();
			var $url=node.attr("data-url");
			var $code=$.base64.encode(node.attr("data-code"));
			$("#sidebar").children().removeClass("active");
			node.parent().parent().parent().addClass("active");
			$.hash("code",$code);
			$("#my_container").load($url,function(response){
				if(response.indexOf('login.html_kewwords')>0){
					toastr['error']("登录超时！请重新登陆");
					location.href="/Admin/Main/login?login_type="+$.cookie('l_t')+"&shop_id="+$.cookie('s_d')+"&soft_version="+$.cookie('s_v');
				}
				close_loading();
			});
	}
	/**初始化表单验证器*/
	function init_parsley(node){
    	$("#validate-form").parsley({
        successClass: 'has-success',
        errorClass: 'has-error',
        errors: {
            classHandler: function(el) {
                return $(el).closest('.form-group');
            },
            errorsWrapper: '<ul class=\"help-block list-unstyled\"></ul>',
            errorElem: '<li></li>'
        }
		});
		return false;
	}
	//**存柜设置*/
	function store_set_dailog(){
		$msg='设置前请您将卡放到读卡器上！';
		$title='存柜设置';
		 bootbox.dialog({
            message:$msg,
            title: $title,
            className:"delete_dialog",
            buttons: {
                    success: {
                      label: "不能开柜",
                      className: "btn-default",
                      callback: function() {
                      	var csharp=window.external;
						var flag=csharp.StaffCardSet(0);
						if(flag=='0'){
							toastr["success"]("操作成功！");
						}else{
							toastr['error']("失败",csharp.GetError(flag));
						}
                    }
                  },
                  danger: {
                    label: "能开柜",
                    className: "btn-danger",
                    callback: function() {
                    	var csharp=window.external;
						var flag=csharp.StaffCardSet(1);
						console.log(flag);
						if(flag=='0'){
							toastr["success"]("操作成功！");
						}else{
							toastr['error']("失败",csharp.GetError(flag));
							
						}
                    }
                }
            }
        });
	
		
	}
	/***
	 * 点击删除按钮 弹出框
	 * @param url 地址
	 * @msg  弹出消息
	 * @refresh 是否刷新
	 * @delete_model_card_no 删除卡号是 delete_model_card_no  的模板
	 * */
	function delete_dialog(url,msg,refresh,delete_model_card_no){
		if(refresh=='undefined'||refresh==null){
			refresh=true;
		}
		var $msg=msg;
		var $title='';
		if($msg==null||$msg=='undifined'||$msg==''){
			$msg='您确定要删除吗';
			$title='删除';
		}else{
			$msg='您确定要操作吗';
			$title='操作';
		}
		 bootbox.dialog({
            message:$msg,
            title: $title,
            className:"delete_dialog",
            buttons: {
                    success: {
                      label: "取消",
                      className: "btn-default",
                      callback: function() {
                      	
                    }
                  },
                  danger: {
                    label: "确定",
                    className: "btn-danger",
                    callback: function() {
                    	$.post(
                    		url,
                    		function(data){
                    			if(data.flag){
                    				if(delete_model_card_no!='undefined'&&delete_model_card_no!=null){
                    					clear_model(delete_model_card_no);
                    				}
                    				toastr['success']("操作成功");
                    				if(refresh){
                    					$("#myform #btn-advanced-refresh").trigger("click");// 刷新页面	
                    				}
                    			}else{
                    				toastr['error'](data.msg,"操作失败");
                    			}
                    		}
                    	)
                    }
                }
            }
        });
	}

    /**点击导出按钮 弹出框*/
    function export_dialog(url) {
        bootbox.dialog({
            title: "请选择导出数据行数",
            message:'<form class="form-inline">\n' +
            '  <div class="form-group">\n' +
            '    <label for="exampleInputName2">从</label>\n' +
            '    <input type="text" class="form-control" id="start_row" value="1" placeholder="起始数据行数">\n' +
            '  </div>行\n' +
            '  <div class="form-group">\n' +
            '    <label for="exampleInputEmail2">到</label>\n' +
            '    <input type="text" class="form-control" id="end_row" value="1000" placeholder="结束数据行数">\n' +
            '  </div>行\n'+
            '</form>',
            buttons: {
                danger: {
                    label: "取消",
                    className: "btn-default",
                    callback: function() {

                    }
                },
                success: {
                    label: "确定",
                    className: "btn-success",
                    callback: function() {
                    	var	start_row = $('#start_row').val();
                    	var end_row = $('#end_row').val();
                    	if (start_row > end_row) {
                            toastr['error']("起始行数不能大于结束行数");
                            return false;
						}
                    	if (end_row - start_row > 10000) {
                            toastr['error']("数据总条数不能超过10000条");
                            return false;
						}
                         url = url + '&start_row=' + start_row + '&end_row=' + end_row;
                        location.href=url;
                        return false;
                    }
                }
            }
        });
    }

	///配卡
	function fetch_card(card_no){
		if(is_auto_read()){
			return false;
		}
		var csharp = window.external;
		var $flag=csharp.QueryCard(card_no);
		if($flag=='0'){
			toastr['success']("成功","成功！");
			return false;
		}else{
			toastr['error'](csharp.GetError($flag),"失败！");
			return false;
		}
	}
	/***
	 * 设置水泵
	 * type 类型 0 无效 1自助充值 2无限次  3人工充值
	 * */
	function set_water_pump(type,count,minute){
		var csharp = window.external;
		var $flag=csharp.SetWaterPump(type,count,minute);
		console.log("水控写--"+$flag);
		if($flag=='0'){
			return true;
		}else{
			toastr['error'](csharp.GetError($flag),"失败！");
			return false;
		}
	}
	/**
	 * 设置水控
	 * */
	function get_water_pump(){
		var csharp = window.external;
		var $flag=csharp.GetWaterPump();
		console.log("水控读--"+$flag);
		if($flag.indexOf(",")>0){
			$flag=$flag.split(",");
			$msg="";
			if($flag.length==3){
				$msg="充值类型："+$flag[0]+"<br/>剩余次数: "+$flag[1]+"次 <br/>充值时间: "+$flag[2]+"分钟  <br/>";
			}else if($flag.length==4){
				$msg="剩余次数: "+$flag[1]+"次 <br/>充值时间: "+$flag[2]+"分钟  <br/>剩余时间: "+$flag[3];	
			}
			
			bootbox.dialog({
            message:$msg,
            title: "查询",
            className:"delete_dialog",
            buttons: {
                    success: {
                      label: "取消",
                      className: "btn-default",
                      callback: function() {
                      	
                    }
                  },
            }
        });
			return true;
		}else{
			toastr['error']($flag,"失败！");
			return false;
		}
	}
	
    /**
	 *更具柜号查询会员
	 */
	function read_no_member(){
		if(is_auto_read()){
			return false;
		}
		var csharp=window.external;
		var flag=csharp.ReadNoNumber();
		if(flag>'0'){
			$.post(
				"/admin/member/find_bycard",
				{"card_no":flag},
				function(data){
				  console.log(data);
					if(data.flag){
						var msg="<H3>姓名："+data.data.name+"<br />"+"电话："+data.data.mobile+"<br />"+"卡号："+data.data.card_no+"</H3>";
						bootbox.alert({
						    message: msg,
						    size: 'large',
						    className: 'bb-alternate-modal'
						});
						return true;
					}else{
						toastr['error'](data.msg,"失败！"); 
						return false;
					}
				}
			);
		
		}else{
			toastr['error']("失败",csharp.GetError(flag));
			return false;
		}		
	}	
	
	/**
	 *设置员工卡是否能开柜子 
	 */
	function set_staff_card(obj){
		try{
			var csharp=window.external;
			var flag=csharp.StaffCardSet(obj);
			console.log("参数:"+obj+",StaffCardSet-flag",flag);
			if(flag=='0'){
				return true;
			}else{
				toastr['error']("失败",csharp.GetError(flag));
				return false;
			}
		}catch(e){
			alert(e.message);
		}finally{
			//close_loading();
		}
	}
	/**
     * 柜号查询 查询机
     **/
    function read_cupno(){
		if(is_auto_read()){
			return false;
		}
		try{
			var csharp=window.external;
		    var result=csharp.ReadSmartCupNo();
	    	if(result=="没有查询到"||result=="-1"){//读卡错误
				toastr['error']("没有查询到");
			}else{
				result=jQuery.parseJSON(result);
				console.log(result);
				if(result["cupno"]=="0"){
					if(result["rentcupno"]=="0"){
						toastr['error']("您暂时未存储物品");
					}else{
						toastr['success'](result["rentcupno"]);
					}
				}else{
					toastr['success'](result["cupno"]+","+result["rentcupno"]);	
				}
			}
		}catch(e){
			alert(e.message);
		}finally{
			return false;	
		}
    }
	/**
	 * 写权限编号
	 * */
	function write_card_btn(node,auth){
		if(is_auto_read()){
				return false;
		}
		var csharp=window.external;
		var num=csharp.WriteAuth(auth);		
		if(num<0){//写卡错误
			toastr['error'](csharp.GetError(num));
		}else{
			toastr['success']("写卡成功权限编号："+num);
		}
	}
	//开启自动读卡
	function js_stop_auto_read(){
		var csharp=window.external;
		console.log("停止自动读卡");
		csharp.JsStopAutoRead();
		return false;
	}
	//关闭自动读卡
	function js_start_auto_read(){
		console.log("开始自动读卡");
		var csharp=window.external;
		csharp.JsStartAutoRead();
		return false;
	}
	/**
	 * 设备重连
	 **/
	function reconnect(){
		var csharp=window.external;
		var flag=csharp.Reconncet();
		
		console.log(flag=="0");
		if(flag=="0"){
			toastr['success']("成功");
		}else{
			toastr['error'](csharp.GetError(flag));
		}
		return false;
	}
	function clear_model(card_no){
		if(card_no==null||card_no=='undifined'||card_no.length<3){
			return false;
		}else{
			try{
				var csharp=window.external;
				csharp.ClearModel(card_no);	
				return true;
			}catch(e){
				return false;
			}
		}
	}
	/**
	 *设置通店储物柜
	 **/
	function common_cabinet(){
		try{
			var csharp=window.external;
			var res= csharp.CommonCabinet();
			if(res.length>3){
				loading();
				$.post(
					"/Admin/CommonCabinet/addPost",
					{"card_no":res},
					function(data){
						close_loading();
						toastr['success']("成功");
						return;
					}
				);
			}else{
				toastr['error']("设置失败"+res);
			}
			return true;
		}catch(e){
			toastr['error']("请先升级版本");
			return false;
		}
	}
	
	function sync_card_no_btn(){
		var $card_no=$("#sync_card_no").val();
		var $shop_id=$("#sync_shop_id").val();
		if($card_no==null||$card_no.length<5){
			toastr['error']("卡号错误");
		}else{
			$.post(
				'/Api/GymApi/getFaceCode',
				{
					"card_no":$card_no,
					"shop_id":$shop_id,
				},
				function(data){
					 if(data.flag){
					 	var csharp=window.external;
					 	try{
					 		csharp.WriteTxt($card_no,data.data.face1);
					 	}catch(e){
					 		toastr['error']("请先升级版本");
							return false;
					 	}
						var $signs=data.data.signs;
						var $count=data.data.count;
						$("#sign_count").text($count);
						$("#sign_list").empty();
						$.each($signs,function(index,value){
							$content='<div class="col-sm-2"><div class="col-sm-12"><img alt="暂无图片" src="';
							$content+=value['icon1']+'"';//'https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=3349216825,2698183703&fm=179&app=42&f=JPEG?w=121&h=140"';
							$content+=' style="width: 100%;max-height: 80px;" class="img-circle" style="margin: 1px;" /></div><div class="col-sm-12 text-center"><span class="span3">';
							$content+=value['name'];
							$content+=' </span></div></div>';
							$("#sign_list").append($content);
						});
					 	toastr['success']("成功"); 
					 	$("#sync_card_no").val();
					 }else{
					 	toastr['error'](data.msg);
					 }
				}
			);
			return false;
		}
	}
	/**
	 * 读卡按钮
	 * node 需要赋值的节点
	 * flag  是否需要清卡
	 * open_door 是否能开柜
	 */
	function read_staff_card_btn(node,flag,open_door){
		if(is_auto_read()){
				return false;
		}		
		try{
			var csharp=window.external;
			var flag=csharp.StaffCardSet(open_door);//设置能否开柜
			if(flag<0){
				toastr['error'](csharp.GetError(flag));
				return false;
			}
			var card_no=csharp.ReadCard();
			if(card_no<0){//读卡错误
				toastr['error'](csharp.GetError(card_no));
				return false;
			}else{
				$(node).val(card_no);
				return true;
			}	
		}catch(e){
			alert(e.message);
		}
	}
	
	/**
	 * 读取区域门禁编号 
	 **/
	function read_card_code_btn(node){
		if(is_auto_read()){
				return false;
		}
		var csharp=window.external;
		var num=csharp.ReadAuth();
		
		if(num<0){//读卡错误
			toastr['error'](csharp.GetError(num));
		}else{
			toastr['success']("读卡成功权限编号："+num);
		}
	}
	//第一次指纹触发事件
	function sign_finger1(){
	  var csharp=window.external;
	  csharp.SignFinger1();
	  console.log("finger1");
	}
	//第二次指纹触发事件
	function sign_finger2(){
	  var csharp=window.external;
	  csharp.SignFinger2();
	  console.log("finger2");
	}
	//指纹第一次录入指纹
	function SignFinger1CallBack(data){
			$("#finger_image1").attr("src",data);
			console.log("第一次指纹会调");
			//alert("第一次录制成功,请抬起手指在按一次");
	}
	//指纹第二次录入指纹
	function SignFinger2CallBack(data){
		    console.log("第二次指纹会调");
			$("#finger_image2").attr("src",data);			
	}
	//第一次和第二次比对
	function FingerDataCallBack(status_){
			if(status_==null||status_==""||status_.length<10){
				console.log("指纹比对会调失败");	
				toastr["error"]("2次指纹不一致","错误提示！","错误提示");
			}else{
				console.log("指纹比对会调成功");
				$("#fingerprint").val(status_);
				toastr["success"]("指纹录入成功");
			}
	}
	function open_camare(type){
		var csharp=window.external;
		console.log(type);
		if(type==0){
			csharp.OpenCamare();
		}else{
			type = arguments[0] ? arguments[0] : "1"; 
			csharp.OpenCamare(type);	
		}	
	}
	//获取人脸模板
	function get_face_code(){
		var csharp=window.external;
		var result= csharp.GetFaceCode();
		console.log(result);
		return result;
		
	}
	//获取人脸url
	function get_face_url(){
		var csharp=window.external;
		return csharp.GetFaceUrl();
		
	}
	
	//写人脸 txt
	function write_txt_face(card_no,datas){
		var csharp=window.external;
		return csharp.WriteTextFace(card_no,datas);
		
	}
	//写指纹 txt
	function write_txt_finger(card_no,datas){
		var csharp=window.external;
		return csharp.WriteTextFinger(card_no,datas);
		
	}
	
	//获取人脸url
	function get_face_url(){
		var csharp=window.external;
		return csharp.GetFaceUrl();
		
	}
	//中央店清理 c1-c80
	function clear_store_zyd(){
		  var csharp = window.external;
		 	bootbox.dialog({
	            message:"您确定要清理(c1-c80)租柜吗？",
	            title: "警告",
	            className:"delete_dialog",
	            buttons: {
	                    success: {
	                      label: "取消",
	                      className: "btn-default",
	                      callback: function() {
	                      	
	                    }
	                  },
	                  danger: {
	                    label: "确定",
	                    className: "btn-danger",
	                    callback: function() {
	                    	///public int OursCLearCup(bool isnew,bool isRent)
	                    	 var $flag=csharp.OursCLearCup();
							  if($flag=='0'){
										toastr['success']("成功","成功！");
									}else{
										toastr['error']("失败",csharp.GetError($flag));
								}
	                    }
	                }
            	}
        	});
	}
	//清柜
	function clear_store(flag){
  	      var csharp = window.external;
  	    if(flag=="true"){// 租柜
		 	bootbox.dialog({
	            message:"您确定要清理租柜吗？",
	            title: "警告",
	            className:"delete_dialog",
	            buttons: {
	                    success: {
	                      label: "取消",
	                      className: "btn-default",
	                      callback: function() {
	                      	
	                    }
	                  },
	                  danger: {
	                    label: "确定",
	                    className: "btn-danger",
	                    callback: function() {
	                    	 var $flag=csharp.ClearCupNo(flag);
							  if($flag=='0'){
										toastr['success']("成功","成功！");
									}else{
										toastr['error']("失败",csharp.GetError($flag));
								}
	                    }
	                }
            	}
        	});
  	      }else{//临时柜
  	      	 	var $flag=csharp.ClearCupNo(flag);
		  		if($flag=='0'){
					toastr['success']("成功","成功！");
				}else{
					toastr['error']("失败",csharp.GetError($flag));
				}
  	      		return true;
  	      }
		return true;
	}
	//是否自动读卡
	function is_auto_read(){
//		var csharp=window.external;
//		var flag=csharp.IsAutoRead();
//		if(flag){
//			toastr['error']("请关闭自动读卡","错误提示");
//		}
		return false;
	}
	//获取会员信息
	function get_member_info(card_no){
		var csharp=window.external;
		var member=csharp.GetMemberInfo(card_no);
		return member;
	}
	//toastr 初始化配置
	function init_toastr(){
		toastr.options = {
		"closeButton": true,
		"debug": true,
		"progressBar": true,
		"positionClass": "toast-top-center",
		"showDuration": "300",
		"hideDuration": "1000",
		"timeOut": "2000",
		"extendedTimeOut": "1000",
		"showEasing": "swing",
		"hideEasing": "linear",
		"showMethod": "fadeIn",
		"hideMethod": "fadeOut"
		}
	}
	
	//jQuery.filer  文件上传配置
     window.filer_default_opts = {
        changeInput2: '<div class="jFiler-input-dragDrop"><div class="jFiler-input-inner"><div class="jFiler-input-icon"><i class="icon-jfi-cloud-up-o"></i></div><div class="jFiler-input-text"><h3>Drag&Drop files here</h3> <span style="display:inline-block; margin: 15px 0">or</span></div><a class="jFiler-input-choose-btn blue-light">点击 或 拖拽文件</a></div></div>',
        limit: null,
        templates: {
            box: '<ul class="jFiler-items-list jFiler-items-grid"></ul>',
            item: '<li class="jFiler-item" style="width: 49%">\
                        <div class="jFiler-item-container">\
                            <div class="jFiler-item-inner">\
                                <div class="jFiler-item-thumb">\
                                    <div class="jFiler-item-status"></div>\
                                    <div class="jFiler-item-info">\
                                        <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                        <span class="jFiler-item-others">{{fi-size2}}</span>\
                                    </div>\
                                    {{fi-image}}\
                                </div>\
                                <div class="jFiler-item-assets jFiler-row">\
                                    <ul class="list-inline pull-left">\
                                        <li>{{fi-progressBar}}</li>\
                                    </ul>\
                                    <ul class="list-inline pull-right">\
                                        <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                    </ul>\
                                </div>\
                            </div>\
                        </div>\
                    </li>',
            itemAppend: '<li class="jFiler-item" style="width: 49%">\
                            <div class="jFiler-item-container">\
                                <div class="jFiler-item-inner">\
                                    <div class="jFiler-item-thumb">\
                                        <div class="jFiler-item-status"></div>\
                                        <div class="jFiler-item-info">\
                                            <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                            <span class="jFiler-item-others">{{fi-size2}}</span>\
                                        </div>\
                                        {{fi-image}}\
                                    </div>\
                                    <div class="jFiler-item-assets jFiler-row">\
                                        <ul class="list-inline pull-left">\
                                            <li><span class="jFiler-item-others">{{fi-icon}}</span></li>\
                                        </ul>\
                                        <ul class="list-inline pull-right">\
                                            <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                        </ul>\
                                    </div>\
                                </div>\
                            </div>\
                        </li>',
            progressBar: '<div class="bar"></div>',
            itemAppendToEnd: false,
            removeConfirmation: true,
            _selectors: {
                list: '.jFiler-items-list',
                item: '.jFiler-item',
                progressBar: '.bar',
                remove: '.jFiler-item-trash-action'
            }
        },
        dragDrop: {},
        uploadFile: {
            url: "/admin/UploaderFile/upload",
            data: {},
            type: 'POST',
            enctype: 'multipart/form-data',
            beforeSend: function(){},
            success: function(data, el){
                var parent = el.find(".jFiler-jProgressBar").parent();
                el.find(".jFiler-jProgressBar").fadeOut("slow", function(){
                    $("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> Success</div>").hide().appendTo(parent).fadeIn("slow");
                });
                $("#pics").val($("#pics").val()+","+data);
                console.log($("#pics").val());
            },
            error: function(el){
                var parent = el.find(".jFiler-jProgressBar").parent();
                el.find(".jFiler-jProgressBar").fadeOut("slow", function(){
                    $("<div class=\"jFiler-item-others text-error\"><i class=\"icon-jfi-minus-circle\"></i> Error</div>").hide().appendTo(parent).fadeIn("slow");    
                });
            },
            statusCode: null,
            onProgress: null,
            onComplete: null
        },
        onRemove: function(itemEl, file, id, listEl, boxEl, newInputEl, inputEl){
        	console.log(file);
            var file = file.name;
            $.post('/admin/UploaderFile/delete', {file: file,"dir":"upload"});
        },
        captions: {
			button: "选择文件",
			feedback: "选择文件上传",
			feedback2: "文件已经被选中",
			drop: "拖拽文件到此处上传",
			removeConfirmation: "您确定删除此文件吗?",
			errors: {
			filesLimit: "最多能上传 {{fi-limit}} 个文件.",
			filesType: "只能上传指定类型文件.",
			filesSize: "{{fi-name}} -文件大小超出限制!最大允许上传 {{fi-maxSize}} MB.",
			filesSizeAll: "上传的文件的总大小不得超过 {{fi-maxSize}} MB."
			}
		}
    };
	$('#sync_card_no').select2({
	    	placeholder: "请输入手机号/卡号/姓名",
	    	minimumInputLength: 2 ,
	    	ajax:{
	    		delay:300,
	    		url:"/admin/Member/SearchMember",
	    		data:function(param){
	    			var query={
	    				q:param.term,
	    				t:123456
	    			}
	    			return query;
	    		},
	    		processResults: function (data) {
				    return {
				      results: data
				    };
  				},
	    	}
	    })
	
	/**
	 * 根据3级菜单 拆分成  xxxx,xxxxxxxx,xxxxxxxxxxxx模式
	 * @param code  第三级代码菜单
	 * */
	function code_spilt(code){
		if(code.length==8){//代码正确
			var menu_1=code.substring(0,4);//第一级菜单
			var menu_2=code.substring(0,8);//第二级菜单
			return [menu_1,menu_2];
		}else{
			alert("禁止非法访问！！！");
			return false;
		}
	}
	/**个人信息修改**/
	$("#modify_info").click(function(){
		$("#10031000").trigger("click");
	});
	/**个人密码修改**/
	$("#modify_psw").click(function(){
		$("#10031001").trigger("click");
	});
	
})()
	

